<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DB;
use Storage;
class DownloadController extends Controller
{
    //
    public function download($id)
    {
    	$res = DB::table('games') -> where('id',$id) -> first();
    	$name = $res -> file;
    	$time = $res -> time;
    	$time = date('Ymd',$time);
    	$path = './uploads/games/files/'.$time.'/'.$name;
        $num = strrpos($res -> file,'.');
        $extension = substr($res -> file,$num);
       
    
    	return response() -> download($path,$disposition = $res -> name.$extension);
    	
    }
}
